

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Index, Trigger, Check Constraint [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Data Modeling,Data Modeling Index,Data Modeling Trigger Operation,Data Modeling Check Constraint,Data Modeling Sorted Lookup Table,Index,Index Create in Data Modeling,Index What Is An?,Sorted Lookup Table,Sorted Lookup Table Create In Data Modeling,Trigger Operation,Trigger Operation Create,Trigger Operation What Is A?,Check Constraint,Check Constraint Create,Check Constraint What Is A?,Create,Create Trigger Operation,Create Index (Data Modeling),Create Sorted Lookup Table,Create Check Constraint,What Is,What Is A Check Constraint?,What Is A Trigger Operation?,What Is An Index?,Trigger,Trigger Operation, What Is A?">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Index, Trigger, Check Constraint</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="views.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="generateddl.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_SubHeadingL1"><span class="f_SubHeadingL1">What is an Index?</span></p>
<p class="p_BodyText"><span class="f_BodyText">An index is a sorted look-up for a table. When it is known in advance that a table must be sorted in a specific order, it is usually worth the small processing overhead to always maintain a sorted look-up list rather than sort the table every time it is required. In Enterprise Architect, an index is modeled as a stereotyped operation. On generating DDL, the necessary instructions for generating indexes are written to the DDL output.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">What is a Trigger?</span></p>
<p class="p_BodyText"><span class="f_BodyText">A trigger is an operation automatically executed as a result of the modification of data in the database, and usually ensures consistent behavior of the database. For example, a trigger might be used to define validations that must be performed every time a value is modified, or might perform deletions in a secondary table when a record in the primary table is deleted. In Enterprise Architect, a trigger is modeled as a stereotyped operation. Currently Enterprise Architect does not generate DDL for triggers, but nonetheless they aid in describing and specifying the table structure in detail.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">What is a Check Constraint?</span></p>
<p class="p_BodyText"><span class="f_BodyText">A </span><span class="f_BodyText" style="font-style: italic;">Check Constraint</span><span class="f_BodyText"> enforces domain integrity by limiting the values that are accepted by a column.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Create an Index</span></p>
<ol style="text-indent: 0px; margin-left: 48px; list-style-position: outside;">
<li value=1><span class="f_NumberedList">Right-click on the required table either in a diagram or in the </span><span class="f_UIControl">Project Browser</span><span class="f_NumberedList">.</span></li>
<li value=2><span class="f_NumberedList">Select the </span><span class="f_MenuKeyField">Operations</span><span class="f_NumberedList"> context menu option. The </span><span class="f_UIControl">Operations</span><span class="f_NumberedList"> dialog displays.</span></li>
<li value=3><span class="f_NumberedList">Add an operation (with a name such as</span><span class="f_NumberedList" style="font-style: italic;"> IDX_CustomerID</span><span class="f_NumberedList">; the </span><span class="f_NumberedList" style="font-style: italic;">IDX_</span><span class="f_NumberedList"> prefix is optional but it helps identify the operation).</span></li>
<li value=4><span class="f_NumberedList">In the </span><span class="f_MenuKeyField">Stereotype</span><span class="f_NumberedList"> field for the operation, select </span><span class="f_MenuKeyField">index</span><span class="f_NumberedList"> (</span><span class="f_MenuKeyField">check</span><span class="f_NumberedList"> and </span><span class="f_MenuKeyField">unique</span><span class="f_NumberedList"> are also supported).</span></li>
<li value=5><span class="f_NumberedList">Click on the </span><span class="f_UIControl">Column</span><span class="f_NumberedList"> tab.</span></li>
<li value=6><span class="f_NumberedList">Add the required columns in the required order then click on the </span><span class="f_MenuKeyField">Save</span><span class="f_NumberedList"> button to save changes.</span></li>
</ol>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Create a Check Constraint or Trigger</span></p>
<ol style="text-indent: 0px; margin-left: 48px; list-style-position: outside;">
<li value=1><span class="f_NumberedList">Locate the required table in either a diagram or the </span><span class="f_UIControl">Project Browser</span><span class="f_NumberedList">.</span></li>
<li value=2><span class="f_NumberedList">Use the context menu to open the </span><span class="f_UIControl">Operations</span><span class="f_NumberedList"> dialog.</span></li>
<li value=3><span class="f_NumberedList">Add an operation (such as </span><span class="f_NumberedList" style="font-style: italic;">CHK_ColumnName</span><span class="f_NumberedList"> or </span><span class="f_NumberedList" style="font-style: italic;">TRG_OnCustomerUpdate</span><span class="f_NumberedList">; the </span><span class="f_NumberedList" style="font-style: italic;">CHK_</span><span class="f_NumberedList"> and </span><span class="f_NumberedList" style="font-style: italic;">TRG_</span><span class="f_NumberedList"> prefixes are optional but help identify the operation</span><span class="f_NumberedList">).</span></li>
<li value=4><span class="f_NumberedList">In the </span><span class="f_MenuKeyField">Stereotype</span><span class="f_NumberedList"> field for the constraint, select </span><span class="f_MenuKeyField">check</span><span class="f_NumberedList"> or </span><span class="f_MenuKeyField">trigger</span><span class="f_NumberedList"> as appropriate and click on the </span><span class="f_MenuKeyField">Save</span><span class="f_NumberedList"> button to save changes.</span></li>
<li value=5><span class="f_NumberedList">Select the constraint operation, then the</span><span class="f_UIControl"> Behavior</span><span class="f_NumberedList"> tab.</span></li>
<li value=6><span class="f_NumberedList">Enter the entire check constraint clause (e.g. </span><span class="f_MenuKeyField">col1 &lt; 1000</span><span class="f_NumberedList">), or the entire trigger code (including the </span><span class="f_NumberedList" style="font-style: italic;">CREATE_TRIGGER</span><span class="f_NumberedList"> statement) in the</span><span class="f_MenuKeyField"> Initial Code</span><span class="f_NumberedList"> field and click on the </span><span class="f_MenuKeyField">Save</span><span class="f_NumberedList"> button to save changes.</span></li>
</ol>
<p class="p_BodyText"><span class="f_BodyText">&nbsp;</span></p>
<p class="p_BodyText"><span class="f_BodyText">The example below shows how an index looks in a diagram (in the </span><span class="f_BodyText" style="font-style: italic;">Order</span><span class="f_BodyText"> element):</span></p>
<p class="p_TextIndentedL2"><img src="indexestriggers.png" width="466" height="529" border="0" alt="IndexesTriggers"></p>




            </div>
          </div>
        </div>



</div>


</body>
</html>
